package com.vincent.message;

import com.vincent.common.Message;
import com.vincent.common.MessageType;
import com.vincent.utils.BallotNumber;
import com.vincent.utils.PValue;
import com.vincent.utils.PValueSet;

/**
 * Created by wensen on 2016/12/8.
 * 由Scout发送至Leader的信息，表示p1a阶段的成功
 * 包含了ballot和Aceptor已接受的PValue信息
 *
 */
public class AdoptedMessage extends Message {

    private BallotNumber ballot_number;
    private PValueSet accepted;

    public AdoptedMessage(int src, BallotNumber ballot, PValueSet  pvalueset) {
        super(src);
        this.ballot_number = ballot;
        this.accepted = pvalueset;
    }

    public void addPValue(PValue pv) {
        this.accepted.add(pv);
    }

    public BallotNumber ballot_number() {
        return this.ballot_number;
    }

    public PValueSet accepted() {
        return accepted;
    }

    public int messageType() {
        return MessageType.ADOPTEDMESSAGE;
    }
}
